<?php

namespace App\Console\Commands;

use App\server\RedisServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class weekFloorRanking extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:nameWeek';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        //存储一周的数据
        $redis= RedisServer::createRedisObject();
        $redis->select(13);
        $day= $redis->zRevRange('week',0,-1);
        $arr=[];
        foreach ($day as $item =>$value){
            $arr['reals_name']=$item;
            $arr['Ranking_browse']=$value;
            $arr['status']=2;
            $arr['created_at']=date('Y-m-d H:i:s');
            $say[]=$arr;
            DB::table('zfm_rankings')->insert($arr);
        }
        $redis->del('week');
    }
}
